//
// Created by wze-zero on 2024/9/17 017.
//
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int n, m, value, count = 0;
    cin >> n >> m;
    int num[n][m];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> num[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> value;
            if (num[i][j] == value) {
                count++;
            }
        }
    }
    cout << fixed << setprecision(2) << ((double) count / (n * m)) * 100 << endl;
    return 0;
}